<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <title>跟踪上个月访问页面的次数</title>
</head>
<body>
<script>
    var visitCounter = localStorage.getItem('visitCounter');
    var firstVisited = localStorage.getItem('firstVisited');
    var now = new Date();

    if (!visitCounter) {
        visitCounter = 0;
        firstVisited = now.toUTCString();
    }

    var oneMonth = new Date(firstVisited);
    oneMonth.setMonth(oneMonth.getMonth() + 1);

    if (now > oneMonth) {
        visitCounter = 0;
        firstVisited = now.toUTCString();
    }

    visitCounter = parseInt(visitCounter) + 1;

    localStorage.setItem('visitCounter', visitCounter);
    localStorage.setItem('firstVisited', firstVisited);

    var output = 'Your\'re visited this page ' + visitCounter + ' times since ' + firstVisited;

    document.write(output);
</script>
</body>
</html>